﻿
 function BBC(sort) {
            var drp2, tvalue
            if (sort == 1) {
                drp2 = document.getElementById("DDPC");
                tvalue = document.getElementById("txtbC").value;
                if (trim(tvalue) == "") {
                    alert('内容不能为空！');
                    return;
                }
            }
            if (sort == 2) {
                drp2 = document.getElementById("DDCCTJ");
                tvalue = document.getElementById("txtCCTJ").value;
                if (trim(tvalue) == "") {
                    alert('内容不能为空！');
                    return;
                }
            }
            if (sort == 3) {
                drp2 = document.getElementById("DDZXBZ");
                tvalue = document.getElementById("txtZXBZ").value;
                if (trim(tvalue) == "") {
                    alert('内容不能为空！');
                    return;
                }
            }
            RemoveAll(drp2)
            var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
            var oDoc = new ActiveXObject("MSXML2.DOMDocument");
           
            oHttpReq.open("POST", "DropChild.aspx?Value=" + tvalue + "&vsort=" + sort, false);         //调用读取小类数据的页面，将大类
            // 编号值传递过去
            oHttpReq.send("");
            result = oHttpReq.responseText;
            //alert(result);
            oDoc.loadXML(result);
            items1 = oDoc.selectNodes("//Goodsothers/Table/Otname");              //读取所有请求大类所属小类的类名
             
            items2 = oDoc.selectNodes("//Goodsothers/Table/Otid");                   //读取所有请求大类所属小类的编号
            var itemsLength = items1.length;
            for (i = 0; i < itemsLength; i++)                                                                 //将小类的类名和编号赋予DropDownList2
            {
                var newOption = document.createElement("OPTION");

                newOption.text = items1[i].text;
                newOption.value = items2[i].text;
                alert('1');
                alert(newOption.text);
                alert('2');
                alert(tvalue);
                drp2.options.add(newOption);
            } 

        }
        function RemoveAll(oElem) {             //清除DropDownList2的所有项
            var i = 0;
            for (i = oElem.length; i >= 0; i--) {
                oElem.options.remove(i);
            }

        }
        function SetSelected(val) {
            var f = document.form1;
            for (i = 0; i < f.select1.options.length; i++) {
                if (f.select1.options(i).value == val) {
                    f.select1.selectedIndex = i
                }
            }
        }
             
        function trim(str){ //删除左右两端的空格
        return str.replace(/(^\s*)|(\s*$)/g, "");
        }